package com.hongxun.budget.greendao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.identityscope.IdentityScopeType;


// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 1): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 1;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(Database db, boolean ifNotExists) {
        CArrivalRecordEntityDao.createTable(db, ifNotExists);
        CBasicsWorkEntityDao.createTable(db, ifNotExists);
        CGoodsDetailEntityDao.createTable(db, ifNotExists);
        CGroundEntityDao.createTable(db, ifNotExists);
        CLinePitEntityDao.createTable(db, ifNotExists);
        CMiddleCheckEntityDao.createTable(db, ifNotExists);
        CPBaseEntityDao.createTable(db, ifNotExists);
        CPolePitEntityDao.createTable(db, ifNotExists);
        CScheduleEntityDao.createTable(db, ifNotExists);
        CScheduleReportEntityDao.createTable(db, ifNotExists);
        CStackPointEntityDao.createTable(db, ifNotExists);
        SysUserEntityDao.createTable(db, ifNotExists);
        APBaseEntityDao.createTable(db, ifNotExists);
        APCostEntityDao.createTable(db, ifNotExists);
        APCriteriaEntityDao.createTable(db, ifNotExists);
        APEstimateEntityDao.createTable(db, ifNotExists);
        APOtherEntityDao.createTable(db, ifNotExists);
        APRangeEntityDao.createTable(db, ifNotExists);
        APWireEntityDao.createTable(db, ifNotExists);
        BBudgetItemEntityDao.createTable(db, ifNotExists);
        BBudgetStandardEntityDao.createTable(db, ifNotExists);
        BCrossQuantitiesEntityDao.createTable(db, ifNotExists);
        BDataDictionaryEntityDao.createTable(db, ifNotExists);
        BDeviceEntityDao.createTable(db, ifNotExists);
        BDeviceQuantitiesEntityDao.createTable(db, ifNotExists);
        BEntryCriteriaEntityDao.createTable(db, ifNotExists);
        BEstimateEntityDao.createTable(db, ifNotExists);
        BMaterialEntityDao.createTable(db, ifNotExists);
        BMaterialQuantitiesEntityDao.createTable(db, ifNotExists);
        BOtherCostEntityDao.createTable(db, ifNotExists);
        BOtherQuantitiesEntityDao.createTable(db, ifNotExists);
        BPointConfigEntityDao.createTable(db, ifNotExists);
        BProjectApplicationEntityDao.createTable(db, ifNotExists);
        DCrossCostEntityDao.createTable(db, ifNotExists);
        DDeviceBuyEntityDao.createTable(db, ifNotExists);
        DDeviceOldEntityDao.createTable(db, ifNotExists);
        DDrawLineEntityDao.createTable(db, ifNotExists);
        DMaterialBuyEntityDao.createTable(db, ifNotExists);
        DMaterialCostEntityDao.createTable(db, ifNotExists);
        DMaterialModelEntityDao.createTable(db, ifNotExists);
        DMaterialModelItemEntityDao.createTable(db, ifNotExists);
        DMaterialOldEntityDao.createTable(db, ifNotExists);
        DOtherCostEntityDao.createTable(db, ifNotExists);
        DPictureEntityDao.createTable(db, ifNotExists);
        DPointEntityDao.createTable(db, ifNotExists);
        DWorkContentEntityDao.createTable(db, ifNotExists);
        ECrossCostEntityDao.createTable(db, ifNotExists);
        EDeviceBuyEntityDao.createTable(db, ifNotExists);
        EDeviceOldEntityDao.createTable(db, ifNotExists);
        EDrawLineEntityDao.createTable(db, ifNotExists);
        EMaterialBuyEntityDao.createTable(db, ifNotExists);
        EMaterialOldEntityDao.createTable(db, ifNotExists);
        EPBaseEntityDao.createTable(db, ifNotExists);
        EPointEntityDao.createTable(db, ifNotExists);
        EPRangeEntityDao.createTable(db, ifNotExists);
        EProblemEntityDao.createTable(db, ifNotExists);
        EProblemexistEntityDao.createTable(db, ifNotExists);
        EPWireEntityDao.createTable(db, ifNotExists);
        EWorkContentEntityDao.createTable(db, ifNotExists);
    }

    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(Database db, boolean ifExists) {
        CArrivalRecordEntityDao.dropTable(db, ifExists);
        CBasicsWorkEntityDao.dropTable(db, ifExists);
        CGoodsDetailEntityDao.dropTable(db, ifExists);
        CGroundEntityDao.dropTable(db, ifExists);
        CLinePitEntityDao.dropTable(db, ifExists);
        CMiddleCheckEntityDao.dropTable(db, ifExists);
        CPBaseEntityDao.dropTable(db, ifExists);
        CPolePitEntityDao.dropTable(db, ifExists);
        CScheduleEntityDao.dropTable(db, ifExists);
        CScheduleReportEntityDao.dropTable(db, ifExists);
        CStackPointEntityDao.dropTable(db, ifExists);
        SysUserEntityDao.dropTable(db, ifExists);
        APBaseEntityDao.dropTable(db, ifExists);
        APCostEntityDao.dropTable(db, ifExists);
        APCriteriaEntityDao.dropTable(db, ifExists);
        APEstimateEntityDao.dropTable(db, ifExists);
        APOtherEntityDao.dropTable(db, ifExists);
        APRangeEntityDao.dropTable(db, ifExists);
        APWireEntityDao.dropTable(db, ifExists);
        BBudgetItemEntityDao.dropTable(db, ifExists);
        BBudgetStandardEntityDao.dropTable(db, ifExists);
        BCrossQuantitiesEntityDao.dropTable(db, ifExists);
        BDataDictionaryEntityDao.dropTable(db, ifExists);
        BDeviceEntityDao.dropTable(db, ifExists);
        BDeviceQuantitiesEntityDao.dropTable(db, ifExists);
        BEntryCriteriaEntityDao.dropTable(db, ifExists);
        BEstimateEntityDao.dropTable(db, ifExists);
        BMaterialEntityDao.dropTable(db, ifExists);
        BMaterialQuantitiesEntityDao.dropTable(db, ifExists);
        BOtherCostEntityDao.dropTable(db, ifExists);
        BOtherQuantitiesEntityDao.dropTable(db, ifExists);
        BPointConfigEntityDao.dropTable(db, ifExists);
        BProjectApplicationEntityDao.dropTable(db, ifExists);
        DCrossCostEntityDao.dropTable(db, ifExists);
        DDeviceBuyEntityDao.dropTable(db, ifExists);
        DDeviceOldEntityDao.dropTable(db, ifExists);
        DDrawLineEntityDao.dropTable(db, ifExists);
        DMaterialBuyEntityDao.dropTable(db, ifExists);
        DMaterialCostEntityDao.dropTable(db, ifExists);
        DMaterialModelEntityDao.dropTable(db, ifExists);
        DMaterialModelItemEntityDao.dropTable(db, ifExists);
        DMaterialOldEntityDao.dropTable(db, ifExists);
        DOtherCostEntityDao.dropTable(db, ifExists);
        DPictureEntityDao.dropTable(db, ifExists);
        DPointEntityDao.dropTable(db, ifExists);
        DWorkContentEntityDao.dropTable(db, ifExists);
        ECrossCostEntityDao.dropTable(db, ifExists);
        EDeviceBuyEntityDao.dropTable(db, ifExists);
        EDeviceOldEntityDao.dropTable(db, ifExists);
        EDrawLineEntityDao.dropTable(db, ifExists);
        EMaterialBuyEntityDao.dropTable(db, ifExists);
        EMaterialOldEntityDao.dropTable(db, ifExists);
        EPBaseEntityDao.dropTable(db, ifExists);
        EPointEntityDao.dropTable(db, ifExists);
        EPRangeEntityDao.dropTable(db, ifExists);
        EProblemEntityDao.dropTable(db, ifExists);
        EProblemexistEntityDao.dropTable(db, ifExists);
        EPWireEntityDao.dropTable(db, ifExists);
        EWorkContentEntityDao.dropTable(db, ifExists);
    }

    /**
     * WARNING: Drops all table on Upgrade! Use only during development.
     * Convenience method using a {@link DevOpenHelper}.
     */
    public static DaoSession newDevSession(Context context, String name) {
        Database db = new DevOpenHelper(context, name).getWritableDb();
        DaoMaster daoMaster = new DaoMaster(db);
        return daoMaster.newSession();
    }

    public DaoMaster(SQLiteDatabase db) {
        this(new StandardDatabase(db));
    }

    public DaoMaster(Database db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(CArrivalRecordEntityDao.class);
        registerDaoClass(CBasicsWorkEntityDao.class);
        registerDaoClass(CGoodsDetailEntityDao.class);
        registerDaoClass(CGroundEntityDao.class);
        registerDaoClass(CLinePitEntityDao.class);
        registerDaoClass(CMiddleCheckEntityDao.class);
        registerDaoClass(CPBaseEntityDao.class);
        registerDaoClass(CPolePitEntityDao.class);
        registerDaoClass(CScheduleEntityDao.class);
        registerDaoClass(CScheduleReportEntityDao.class);
        registerDaoClass(CStackPointEntityDao.class);
        registerDaoClass(SysUserEntityDao.class);
        registerDaoClass(APBaseEntityDao.class);
        registerDaoClass(APCostEntityDao.class);
        registerDaoClass(APCriteriaEntityDao.class);
        registerDaoClass(APEstimateEntityDao.class);
        registerDaoClass(APOtherEntityDao.class);
        registerDaoClass(APRangeEntityDao.class);
        registerDaoClass(APWireEntityDao.class);
        registerDaoClass(BBudgetItemEntityDao.class);
        registerDaoClass(BBudgetStandardEntityDao.class);
        registerDaoClass(BCrossQuantitiesEntityDao.class);
        registerDaoClass(BDataDictionaryEntityDao.class);
        registerDaoClass(BDeviceEntityDao.class);
        registerDaoClass(BDeviceQuantitiesEntityDao.class);
        registerDaoClass(BEntryCriteriaEntityDao.class);
        registerDaoClass(BEstimateEntityDao.class);
        registerDaoClass(BMaterialEntityDao.class);
        registerDaoClass(BMaterialQuantitiesEntityDao.class);
        registerDaoClass(BOtherCostEntityDao.class);
        registerDaoClass(BOtherQuantitiesEntityDao.class);
        registerDaoClass(BPointConfigEntityDao.class);
        registerDaoClass(BProjectApplicationEntityDao.class);
        registerDaoClass(DCrossCostEntityDao.class);
        registerDaoClass(DDeviceBuyEntityDao.class);
        registerDaoClass(DDeviceOldEntityDao.class);
        registerDaoClass(DDrawLineEntityDao.class);
        registerDaoClass(DMaterialBuyEntityDao.class);
        registerDaoClass(DMaterialCostEntityDao.class);
        registerDaoClass(DMaterialModelEntityDao.class);
        registerDaoClass(DMaterialModelItemEntityDao.class);
        registerDaoClass(DMaterialOldEntityDao.class);
        registerDaoClass(DOtherCostEntityDao.class);
        registerDaoClass(DPictureEntityDao.class);
        registerDaoClass(DPointEntityDao.class);
        registerDaoClass(DWorkContentEntityDao.class);
        registerDaoClass(ECrossCostEntityDao.class);
        registerDaoClass(EDeviceBuyEntityDao.class);
        registerDaoClass(EDeviceOldEntityDao.class);
        registerDaoClass(EDrawLineEntityDao.class);
        registerDaoClass(EMaterialBuyEntityDao.class);
        registerDaoClass(EMaterialOldEntityDao.class);
        registerDaoClass(EPBaseEntityDao.class);
        registerDaoClass(EPointEntityDao.class);
        registerDaoClass(EPRangeEntityDao.class);
        registerDaoClass(EProblemEntityDao.class);
        registerDaoClass(EProblemexistEntityDao.class);
        registerDaoClass(EPWireEntityDao.class);
        registerDaoClass(EWorkContentEntityDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

    /**
     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
     */
    public static abstract class OpenHelper extends DatabaseOpenHelper {
        public OpenHelper(Context context, String name) {
            super(context, name, SCHEMA_VERSION);
        }

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(Database db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name) {
            super(context, name);
        }

        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(Database db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

}
